﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NextGEN.Util.Portable.Common.Library.Exceptions;

namespace NextGEN.Util.Portable.Common.Library.Results
{
    public class ValidationResult
    {
        public bool Success { get { return ErrorMessages.Count == 0; } }

        public List<BaseException> ErrorMessages { get; set; }

        public ValidationResult()
        {
            ErrorMessages = new List<BaseException>();
        }

        public ValidationResult(IEnumerable<ValidationResult> validationResults)
            : this()
        {
            foreach (var validationResult in validationResults)
            {
                ErrorMessages.AddRange(validationResult.ErrorMessages);
            }
        }
        
        public ValidationResult(IEnumerable<string> errorMessages)
            : this()
        {
            foreach (var errorMessage in errorMessages)
            {
                ErrorMessages.Add(new BaseException(errorMessage));
            }
        }

        public ValidationResult(IEnumerable<BaseException> errorMessages)
            : this()
        {
            foreach (var errorMessage in errorMessages)
            {
                ErrorMessages.Add(errorMessage);
            }
        }
    }
}
